Skip to content

Conversation

marikola
Copy link
Member

adds classroom creation and some management stuff

@marikola marikola linked an issue Apr 20, 2026 that may be closed by this pull request
@johanaam johanaam changed the title Create classrooms feat: create classrooms Apr 20, 2026
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Kdocs

import java.io.*

@Entity
@Table(name = "classroom_teachers", uniqueConstraints = [UniqueConstraint(columnNames = ["classroom_id", "teacher_user_id"])])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDocs

Copy link
Member

@johanaam johanaam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ALA codex code review

*/
@Transactional(readOnly = true)
fun getClassrooms(): List<Classroom> =
classroomRepository.findAll()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getClassrooms() now returns classroomRepository.findAll(), and the response includes each classroom's joinCode. Because the paired GET /api/v1/classrooms/{id} path also has no membership/ownership check, any authenticated pupil or teacher can enumerate every classroom, inspect rosters/teacher emails, and recover join codes for classes they should not see.

* @throws ResponseStatusException if the classroom does not exist or if one or more teacher emails cannot be resolved.
*/
@Transactional
fun updateClassroom(command: UpdateClassroomCommand): Classroom {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new mutation paths do not verify that the caller owns the classroom: updateClassroom ignores authenticatedSubject, and approvePupil/removePupil do not even receive a principal. As shipped, any authenticated user who knows a classroom id can rename the class, replace its teacher list, approve pending pupils, or remove pupils from someone else's classroom.

@@ -18,14 +21,42 @@ import java.util.*
*
* @property classroomRepository repository for classroom access
* @property currentUserResolver shared resolver for the authenticated user and role guard
* @property userRepository: userRepository repository for user access
*/
@Service
class ClassroomService(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods call classroom.approvePupil/removePupil, which throw IllegalArgumentException when the pupil is not in the classroom. In practice, a stale or mistyped {pupilId} will now surface as a 500 response instead of a client error, so the new endpoints need to translate that case into a ResponseStatusException (for example 404 or 409).

@marikola marikola requested a review from johanaam April 21, 2026 13:14
Copy link
Member

@johanaam johanaam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few conflicts

@marikola marikola merged commit a92d40c into main Apr 21, 2026
1 check passed
@marikola marikola deleted the create-classrooms branch April 21, 2026 14:33
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to create a classroom
2 participants